// we removed an item in the main menu, and we have a more submenu
// we need to extract the first item in more and move it to the submenu
- let apObj = this._overflowItem.menu.firstMenuItem;
- if (apObj.item) {
- apObj.item.destroy();
+ let item = this._overflowItem.menu.firstMenuItem;
+ if (item && item._apObj) {
+ item.destroy();
+ // clear the cycle, and allow the construction of the new item
+ item._apObj.item = null;
- this._createNetworkItem(apObj, NUM_VISIBLE_NETWORKS-1);
+ this._createNetworkItem(item._apObj, NUM_VISIBLE_NETWORKS-1);
+ } else {
+ log('The more... menu was existing and empty! This should not happen');
}
}
// This can happen if the removed connection is from the overflow
// menu, or if we just moved the last connection out from the menu
- if (this._overflowItem.menu.length == 0) {
+ if (this._overflowItem.menu.numMenuItems == 0) {
this._overflowItem.destroy();
this._overflowItem = null;
}
}
if(apObj.connections.length > 0) {
- if (apObj.connections.length == 1)
+ if (apObj.connections.length == 1) {
apObj.item = this._createAPItem(apObj.connections[0], apObj, false);
- else {
+ } else {
let title = apObj.ssidText;
apObj.item = new PopupMenu.PopupSubMenuMenuItem(title);
- apObj.item._apObj = apObj;
for (let i = 0; i < apObj.connections.length; i++)
apObj.item.menu.addMenuItem(this._createAPItem(apObj.connections[i], apObj, true));
}
} else {
apObj.item = new NMNetworkMenuItem(apObj.accessPoints);
- apObj.item._apObj = apObj;
apObj.item.connect('activate', Lang.bind(this, function() {
let accessPoints = sortAccessPoints(apObj.accessPoints);
if ( (accessPoints[0]._secType == NMAccessPointSecurity.WPA2_ENT)
}
}));
}
+ apObj.item._apObj = apObj;
+
if (position < NUM_VISIBLE_NETWORKS) {
apObj.isMore = false;
this.section.addMenuItem(apObj.item, position);